package cn.jbt.api.admin.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.jbt.api.admin.annotation.Log;
import cn.jbt.api.admin.entity.CmsPlaceItem;
import cn.jbt.api.admin.service.ICmsPlaceItemService;
import cn.jbt.common.PageQryParam;
import cn.jbt.common.PageQryResult;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/cms/placeItem")
@Slf4j
@AllArgsConstructor
public class CmsPlaceItemController {

    private final ICmsPlaceItemService iCmsPlaceItemService;

    @PostMapping("/list")
    @SaCheckPermission("cms:placeItem:list")
    @Log(bizType = "查询", bizName = "分页查询推荐信息")
    public PageQryResult<CmsPlaceItem> getAllByPage(@Valid @RequestBody PageQryParam<CmsPlaceItem> pageQryParam) {
        return iCmsPlaceItemService.getAllByPage(pageQryParam);
    }

    @PostMapping("/add")
    @SaCheckPermission("cms:placeItem:add")
    @Log(bizType = "新增", bizName = "新增推荐信息")
    public CmsPlaceItem add(@Valid @RequestBody CmsPlaceItem cmsPlaceItem) {
        return iCmsPlaceItemService.add(cmsPlaceItem);
    }

    @PostMapping("/edit")
    @SaCheckPermission("cms:placeItem:edit")
    @Log(bizType = "编辑", bizName = "编辑推荐信息")
    public CmsPlaceItem edit(@Valid @RequestBody CmsPlaceItem cmsPlaceItem) {
        return iCmsPlaceItemService.edit(cmsPlaceItem);
    }

    @PostMapping("/del")
    @SaCheckPermission("cms:placeItem:del")
    @Log(bizType = "删除", bizName = "删除推荐信息")
    public void del(@NotEmpty @RequestBody List<Long> ids) {
        iCmsPlaceItemService.del(ids);
    }

}
